using System;
using System.Web;
using System.Drawing;
using System.Web.UI;
using System.Web.UI.WebControls	;

namespace WroxControls 
{
   public class MyLabel : Control
   {

      string _text;

      public string Text
      {
         get{ return _text; }
         set{ _text = value; }  
      }

      int _repeatCount = 1;
 
      public int RepeatCount
      {
         get { return _repeatCount; }
         set { _repeatCount = value; }
      }

      Color _foreColor = Color.Blue;

      public Color ForeColor
      {
         get { return _foreColor; }
         set { _foreColor = value; }
      }
      protected override void OnInit(EventArgs e)
      {
         if ( _text == null )
             _text = "Here is some default text";
      }

////// - Version using direct HTML creation
//
//      protected override void Render(HtmlTextWriter writer) 
//      { 
//         int loop;
//         for( loop=0; loop < _repeatCount; loop++ )
//          writer.Write("<h1 style='color:" + ColorTranslator.ToHtml(_foreColor) + "'>" + _text + "</h1>" );
//      }

      protected override void Render(HtmlTextWriter writer) 
      { 
         int loop;
         for( loop=0; loop < _repeatCount; loop++ )
         {

            writer.AddStyleAttribute("color", ColorTranslator.ToHtml(_foreColor) );
            writer.RenderBeginTag("h1");
            writer.Write( _text );
            writer.RenderEndTag();
         }
      }

   }
};
